<!--#include file="../nav/admin_top.php" -->
<style type="text/css">
table.mytable .mylabel{
width:300px;  
}
span.spans{
color:#333333;
margin-left:20px;
}
</style>
<div class="titleDiv">
	<div class="titleCaption">
		<span class="captionSpan">会员列表</span>
		<span class="totalSpan"> <label id="captionNum"></label> </span>
	</div>
</div>
<div class="menuBg">
	<a class="menuAdd" href="{url::build('admin_user','add')}">添加会员</a> 
  <div style="clear:both"></div>
</div>
<div style="margin:10px auto">
	搜索： 
	<select id="state" class="textBox">
		<option value="">--所有状态--</option> 
		<option value="0">意向客户</option> 
		<option value="1">会员</option> 
		<option value="2">暂停</option> 
		<option value="3">取消</option> 
	</select>
	<select id="sendtype" class="textBox">
		<option value="">--所有配送类别--</option> 
		<option value="0">乐园卡</option> 
		<option value="1">田园卡</option> 
	</select>
	<select id="classes" class="textBox">
		<option value="">--所有会员类型--</option>
		<?PHP 
		$list_rs = factory::module('list')->getlist('user_classes');
		foreach($list_rs as $li){
			echo '<option value="'.$li['id'].'">'.$li['val'].'</option>';
		}
		?>
	</select>
	
	
	
	<input type="text" maxlength="12" id="keywords" class="searchs" style="width: " /> 
	<input type="button"  onclick="fnSearchs()" value="查询"  />  	
</div> 
<div id="grids"></div> 
<script type="text/javascript"> 
var url_modify = '/admin_user/modify';
var url_del = '/admin_user/del';
var url_list = '/admin_user/index_list';

$().ready(function(){ 
	o2js.build('o2grid');
	showLoading();
	grids = new o2Grid({
		bind:'grids', 
		url:url_list,
		imgpath:'/misc/vendors/o2js/o2grid/image',
		cols:[
			{index:'id',mapping:'a.id', name:'序号', width:30,sortable:false, func:function(val,row_index,column_name,json,R){
				 return  '<span title="ID：'+json.id+'" >'+((R.page - 1)*R.rowNum + (row_index+1))+'</span>';
			}}, 
			{index:'classes',mapping:'b.val', name:'会员类型', width:100 ,func:function(val,row_index,column_name,json,R){
					if(!val){
						return '';
					}else{
						return val;
					}
				}
			},
			{index:'username',mapping:'a.username', name:'会员编号', width:80,func:function(val,row_index,column_name,json,R){
					return val;
				}
			},  
			{index:'name',mapping:'a.name', name:'会员姓名', width:80 
			},
			{index:'balance',mapping:'a.balance',align:"right", name:'账户余额￥', width:80 
			},
			{index:'bdate',mapping:'a.bdate', name:'服务起止日期',align:"center", width:170 ,func:function(val,row_index,column_name,json,R){ 
						return  json.bdate+' 至 '+json.edate;
				 
				}
			},
			{index:'phone',mapping:'a.phone', name:'手机号码', width:90
			}, 
			{index:'state',mapping:'a.state', name:'账户状态', width:80 ,func:function(val,row_index,column_name,json,R){
					if(val == '0'){
						return  '<span class="red">意向客户</span>';
					}else if(val == '1'){
						return  '<span class="green">会员</span>';
					}else if(val == '2'){
						return '<span class="red">暂停</span>';
					}else{
						return '<span class="red">取消</span>';
					}
				}
			},
			{index:'sendtype',mapping:'a.sendtype', name:'配送类别', width:80 ,func:function(val,row_index,column_name,json,R){
					if(val == '0'){
						return  '<span style="color: ">乐园卡</span>';
					}else if(val == '1'){
						return  '<span style="color:blue">田园卡</span>';
					}
				}
			},
			{index:'id',mapping:'a.id', name:'操作'	, width:80,sortable:false,func:function(val,row_index,column_name,json,R){
					if(val == '1'){
						return ''; 
					}else{
						return   ' <a href="'+url_modify+'?id='+json.id+'" style="color: "  ><img src="/misc/images/edit.gif" />  修改</a> ';
						//' <a href="javascript:void(0)" onclick="fnDel('+json.id+')" ><img src="/misc/images/del.gif" /> 删除</a> '
					}
				}
			}
		]
	});
	fnSearchs();	 
	$('#keywords').keypress(function(e){
		if(e.keyCode==13||e.keyCode==10){
			fnSearchs();
		}
	});
});  
function fnSearchsAll(){
	grids.setBaseParams({
		keywords:''
	}); 
	grids.load(1); 
}
function fnSearchs(){
	grids.setBaseParams({
		keywords:encodeURIComponent($('#keywords').val()),
		state:$('#state').val(),
		classes:$('#classes').val(),
		sendtype:$('#sendtype').val()
	}); 
	grids.load(1); 
} 
/* 删除 */
function fnDel(NId){
	fnConfirm({
		str:'确认删除本行数据?',
		func_true:function(){
			$('button').attr('disabled','disabled');
			$.post(
				url_del,
				{
					id:NId
				},
				function(e){
					var ok = errorHandler(e);
					if(ok && ok.success=='1'){
						window.location.reload();
					}
					$('button').attr('disabled','');
				}
			);
		}
	}); 
}
</script>
<!--#include file="../nav/admin_bottom.php" -->